<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\DB;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    public function __construct(Request $request){
        $this->middleware(function ($request,$next) {
            $session = $request->session()->get("eai");
            if($session){
                $isexist = DB::table('waihui_member_disable')->where(array('userid'=>$session['id']))->first();
                if($isexist){
                    echo "<style>*{margin:0px;padding:0px;}html,body{width:100%;height:100%;background: #dae4e8;}.box{width:400px;height:300px;position: absolute;top:50%;left:50%;margin:-200px -170px;}</style><div class=\"box\"><img src='/images/disabled.png' alt=''></div><a href='/loginout' style='display: block;width: 100px;height: 10px;font-size:15px;position: fixed;left: 0px;top:0px;bottom: 0px;right: 0px;margin: auto;'>切换账号登录</a>";
                    die();
                }else{
                    return $next($request);
                }
            }else{
                return $next($request);
            }
        });
    }
}
 